﻿using System.Collections.Generic;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
using Sustainalytics.Synchronization.Interface;
using System;

namespace Sustainalytics.ClientDW.Synchronization.RiskRatingsBenchmarks.Tests
{
    [Trait("Category", "RiskRating")]
    public class HistoricalDataSyncIntegrationTests
    {
        private readonly ITestOutputHelper output;
        private readonly RiskRatingsHistoricalDataSync _historicalDataSync;

        private readonly SyncContext _syncContext = new SyncContext(ErrorPolicy.BreakRightAway, (x) => Console.WriteLine(x))
        {
            Token = new System.Threading.CancellationToken(),
            GAConnectionStrings = new Dictionary<string, string>
            {
                { "ClientDW", "mongodb://localhost:27017/ClientDW_A" },
                { "RiskRatingsResearchDW", "mongodb://localhost:27017/RiskRatingsResearchDW_A" },
                { "GovernanceDW", "mongodb://localhost:27017/GovernanceDW_A" },
            },
            DSOConnectionStrings = new Dictionary<string, string>(),
            Report = new System.Collections.Concurrent.ConcurrentBag<string>(),
            CompanyUniverses = new Dictionary<Guid, List<int>>(),
            PreviousChanges = new List<ChangedElement>(),
        };

        public HistoricalDataSyncIntegrationTests(ITestOutputHelper output)
        {
            this.output = output;
            var simpleInjectorContainer = SimpleInjectorConfig.Register(new SyncContextLogger(_syncContext), _syncContext.GAConnectionStrings);
            _historicalDataSync = simpleInjectorContainer.GetInstance<RiskRatingsHistoricalDataSync>();
        }

        [Fact]
        public async Task Start()
        { 
            _historicalDataSync.Start(_syncContext.Token);
        }

    }
}
